package com.yanqu.backendweb.vo;

import com.alibaba.fastjson.JSONObject;
import com.yanqu.backendweb.bean.enums.LogType;
import com.yanqu.backendweb.bean.enums.eRoleOtherInfoType;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;

/**
 * @author duli
 * @version 1.0
 * @date 2020/11/4 10:08
 * @Description
 */

@Data
public class LogVo extends PageVo{
    @NotNull
    private LogType log_type;

    private Long user_alias_id;
    /**
     * 角色ID
     */
    private Long role_id;
    /**
     * 条件字段kv
     */
    private JSONObject conditions = new JSONObject();

    public boolean hasCondition(String key) {
        return conditions.containsKey(key);
    }

    public boolean isNotNullCondition(String key) {
        return !isNullCondition(key);
    }

    public boolean isNullCondition(String key) {
        return getCondition(key) == null;
    }

    public boolean isNotBlankCondition(String key) {
        return !isBlankCondition(key);
    }

    public boolean isBlankCondition(String key) {
        return StringUtils.isBlank(conditions.getString(key));
    }
    public <T> T getCondition(String key) {
        return (T) conditions.get(key);
    }

}
